module.exports = (options, app) => {
	return async function routerHandler(ctx, next) {
		const { controller, router, apiRouter } = app;
		// 找到所有接口信息
		const apiList = await app.mongo.find('mock-api', {});
		if (apiList.length) {
			// 注册所有接口
			for (let i = 0; i < apiList.length; i++) {
				const apiInfo = apiList[i];
				const { apiPath, apiType, tableName } = apiInfo;
				apiController = controller.admin.apiCommon[apiType + 'Api'];
				ctx.request.body.tableName = tableName;
				router[apiType](apiPath, apiController);
			}
		}
		await next();
	};
};
